<?php
namespace Zxf5115\Laravel\Advertising\Models\Api;

use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Zxf5115\Laravel\Advertising\Models\Common\Advertising as Common;

/**
 * @author zhangxiaofei [<1326336909@qq.com>]
 * @dateTime 2025-09-22
 *
 * 广告模型类
 */
class Advertising extends Common
{
  /**
   * 需要隐藏的字段
   */
  public $hidden = [
    'organization_id',
    'position_id',
    'sort',
    'status',
    'update_time'
  ];

  // 关联函数 ------------------------------------------------------

  /**
   * 广告与广告位的关联
   *
   * @return [关联对象]
   */
  public function position() : BelongsTo
  {
    return $this->belongsTo(
      'Zxf5115\Laravel\Advertising\Models\Api\Advertising\Position',
      'position_id',
      'id'
    );
  }


  /**
   * 广告与广告详情的关联
   *
   * @return [关联对象]
   */
  public function detail() : HasOne
  {
    return $this->hasOne(
      'Zxf5115\Laravel\Advertising\Models\Api\Advertising\Detail',
      'advertising_id',
      'id'
    );
  }
}
